cmake_minimum_required(VERSION 3.20)

project(ODVLib 
    VERSION 2.0.0
    LANGUAGES CXX
)

set(PROJECT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "项目根目录: ${PROJECT_ROOT_DIR}")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

add_compile_definitions(odvCore_EXPORTS)

add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")    

# 构建前清除构建目录，避免增量编译
file(REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/pyCode/modules/*)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

# osgEarth
find_package(osgEarth REQUIRED)

# osg
find_package(OpenSceneGraph REQUIRED COMPONENTS osgManipulator osgShadow osgSim osgViewer osgGA osgUtil osgText osgDB osg OpenThreads)

# odv
find_package(odv REQUIRED COMPONENTS Core GUI Utils Log)

# Qt
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets)
message(STATUS "Qt5Widgets Path: ${Qt5Widgets_DIR}")
message(STATUS "Qt5Core Path: ${Qt5Core_DIR}")
message(STATUS "Qt5Gui Path: ${Qt5Gui_DIR}")

# python
find_package(Python3 COMPONENTS Interpreter Development)
message(STATUS "Python3_INCLUDE_DIRS:  ${Python3_INCLUDE_DIRS}")

# pybind11
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/pybind11)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/pybind11/include)

# pyodv
add_subdirectory(pyodv)

# src
add_subdirectory(src)

include(GNUInstallDirs)

set(OUT_BIN_DIR ${CMAKE_BINARY_DIR}/bin)
if(NOT EXISTS ${OUT_BIN_DIR})
    file(MAKE_DIRECTORY ${OUT_BIN_DIR})
endif()